package com.raising.modules.com.controller;

import com.raising.framework.controller.BaseController;
import com.raising.framework.entity.ResultVo;
import com.raising.modules.dic.entity.DicRegion;
import com.raising.modules.dic.utils.RegionUtil;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 栏目表 控制器
 * @author gaoy
 * @createTime 2017-12-25 17:09:58
 */
@Controller
@RequestMapping("${frontPath}/region")
public class ComRegionController extends BaseController {

    /**
    * 跳转至列表页面
    * @author gaoy
    * @createTime 2017-12-25 17:09:58
    */
    @RequestMapping(value = "/getCityListByProvinceCd.json", method = RequestMethod.POST)
    public @ResponseBody ResultVo getCityListByProvinceCd(Model model, String provinceCd) {
        List<DicRegion> regionList = RegionUtil.getRegionChildByCd(provinceCd);
        return ResultVo.success().data(regionList);
    }

    /**
     * 根据城市查区
     * @author zhaobx
     * @createTime 2018-01-28 14:35:31
     */
    @RequestMapping(value = "/getCountyListByCityCd.json", method = RequestMethod.POST)
    public @ResponseBody ResultVo getCountyListByCityCd(Model model, String cityCd) {
        olog("根据城市查区","城市cD："+cityCd);
        List<DicRegion> countyList = RegionUtil.getRegionChildByCd(cityCd);
        return ResultVo.success().data(countyList);
    }

}
